// EOFieldDef.cs created with MonoDevelop
// User: awilliam at 9:25 AM 1/10/2008
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//

using System;

namespace Whitemice.EOMono
{
  public class EOFieldDef
  {   
    protected string  name;
    protected string  kind;
    protected bool    isPKey;
    protected IEOValue defaultValue;
    protected string  synonym;
    
    public EOFieldDef(string name,string kind)
      : this(name, kind, false, null, null)
    {
    }
    
    public EOFieldDef(string name, string kind, bool isPKey)
      : this(name, kind, isPKey, null, null)
    {
    }
    
    public EOFieldDef(string name, string kind, bool isPKey, IEOValue defaultValue)
      : this(name, kind, isPKey, defaultValue, null)
    {
    }        

    public EOFieldDef(string _name, string _kind, bool _isPKey, IEOValue _defaultValue, string _syn)
    {
      name = _name;
      kind = _kind;
      isPKey = _isPKey;
      defaultValue = _defaultValue;
      synonym = _syn;
    }
    
    public string Name 
    { 
      get { return name; } 
    } // end Name
      
    internal bool IsPrimaryKey 
    { 
      get { return isPKey; } 
    } // end IsPrimaryKey
    
    internal IEOValue DefaultValue 
    { 
      get  { return defaultValue; } 
      set  { defaultValue = value; }
    }
    
    public string Kind 
    {
      get { return kind; } 
    }
    
    public string Alias 
    { 
      get { return synonym; } 
    } // end Alias
    
    public string AliasedName
    {
      get 
      {
        if (synonym == null)
          return Name;
        return Alias;
      }
    }  // end AliasesName
  }
}
